home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 247_02 / manual2.doc < prev    next >
Encoding:
Text File  |  1989-04-17  |  59.6 KB  |  2,641 lines

  1.                       Appendix III - MIRACL routines
  2.  
  3.  
  4.       Note: In these routines a big parameter can also be used wherever a
  5.             flash is specified, but not visa-versa. Further information may
  6.             be gleaned from the (lightly) commented source code.
  7.  
  8.  
  9.       Function:      void absol(x,y)
  10.                           absol     
  11.                      flash x,y;
  12.  
  13.       Module:        bncore.c
  14.  
  15.       Description:   Gives absolute value of a big or flash number.
  16.  
  17.       Parameters:    Two big/flash variables x and y. On exit y=abs(x).
  18.  
  19.       Return value:  None
  20.  
  21.       Restrictions:  None
  22.  
  23.       See also:      negate
  24.  
  25.  
  26.  
  27.       Function:      void add(x,y,z)
  28.                           add       
  29.                      big x,y,z;
  30.  
  31.       Module:        bnarth0.c
  32.  
  33.       Description:   Adds two big numbers.
  34.  
  35.       Parameters:    Three big numbers x, y and z. On exit z=x+y.
  36.  
  37.       Return value:  None
  38.  
  39.       Restrictions:  None
  40.  
  41.       See also:      subtract, incr, decr.
  42.  
  43.       Example:       add(x,x,x);
  44.  
  45.                      This doubles the value of x.
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.       Function:      void bigdig(x,n,b)
  71.                           bigdig       
  72.                      big x;
  73.                      int n,b;
  74.  
  75.       Module:        bnrand.c
  76.  
  77.       Description:   Generates a big random number of given length.
  78.  
  79.       Parameters:    A big number x and two integers n and b. On exit x
  80.                      contains a big random number n digits long to base b.
  81.  
  82.       Return value:  None
  83.  
  84.       Restrictions:  None
  85.  
  86.       See also:      bigrand
  87.  
  88.       Example:       bigdig(x,100,10);
  89.  
  90.                      This generates a 100 decimal digit random number x
  91.  
  92.  
  93.  
  94.       Function:      void bigrand(w,x)
  95.                           bigrand     
  96.                      big w,x;
  97.  
  98.       Module:        bnrand.c
  99.  
  100.       Description:   Generates a big random number.
  101.  
  102.       Parameters:    Two big numbers w and x. On exit x is a big random number
  103.                      in the range 1<x<w.
  104.  
  105.       Return value:  None
  106.  
  107.       Restrictions:  None
  108.  
  109.       See also:      bigdig
  110.  
  111.  
  112.  
  113.       Function:      int brand()
  114.                          brand  
  115.  
  116.       Module:        bncore.c
  117.  
  118.       Description:   Generates random integer number
  119.  
  120.       Parameters:    None
  121.  
  122.       Return Value:  A random integer number
  123.  
  124.       Restrictions:  First use must be preceded by an initial call to irand.
  125.  
  126.       See also:      irand, bigrand, bigdig, frand.
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.       Function:      void build(x,gener)
  142.                           build         
  143.                      flash x;
  144.                      int (*gener)();
  145.  
  146.       Module:        bnbuild.c
  147.  
  148.       Description:   Uses supplied generator of regular continued fraction
  149.                      expansion to build up a flash number, rounded if
  150.                      necessary.
  151.  
  152.       Parameters:    The flash number created, and the generator function.
  153.  
  154.       Return value:  None
  155.  
  156.       Restrictions:  None
  157.  
  158.       See also:      round, froot, fexp, ftan
  159.  
  160.       Example:       int phi(w,n)
  161.                      flash w;
  162.                      int n;
  163.                      { /* rcf generator for golden ratio */
  164.                           return 1;
  165.                      }
  166.  
  167.                       .
  168.                       .
  169.                      build(x,phi);
  170.                       .
  171.  
  172.                      This will calculate the golden ratio in x - very quickly!
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.       Function:      int cinnum(x,f)
  208.                          cinnum     
  209.                      flash x;
  210.                      FILE *f;
  211.  
  212.       Module:        bnio2.c
  213.  
  214.       Description:   Inputs a flash number from the keyboard, a file or a
  215.                      string, using as number base the current value of the
  216.                      global variable IOBASE. Flash numbers can be entered
  217.                      using either a slash '/' to indicate numerator and
  218.                      denominator, or with a radix point.
  219.  
  220.       Parameters:    A big/flash number x and a file descriptor f. For
  221.                      input from the keyboard specify f as stdin, otherwise
  222.                      as the descriptor of some other opened file. To input
  223.                      from a string copy the string to the global character
  224.                      array IBUFF before calling cinnum. In this case the
  225.                      file descriptor will be ignored and input taken from
  226.                      IBUFF instead. To force input of a fixed number of
  227.                      bytes, set global INPLEN to the required number,
  228.                      just before calling cinnum.
  229.  
  230.       Return value:  The number of input characters.
  231.  
  232.       Restrictions:  None
  233.  
  234.       See also:      innum, otnum, cotnum
  235.  
  236.       Example:       char* chex="AF1298065BFE4C96DB723A";
  237.                               .
  238.                          IOBASE=16;
  239.                          strcpy(IBUFF,chex);
  240.                          cinnum(x,stdin);
  241.  
  242.                      This will input the large hex number chex into the
  243.                      big variable x.
  244.  
  245.                          IOBASE=256;
  246.                          INPLEN=25;
  247.                          cinnum(x,fp);
  248.  
  249.                      This will input 25 bytes from the file associated with
  250.                      fp, and convert them into a big positive number x.
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.       Function:      int compare(x,y)
  274.                          compare     
  275.                      big x,y;
  276.  
  277.       Module:        bncore.c
  278.  
  279.       Description:   Compares two big numbers.
  280.  
  281.       Parameters:    Two big numbers x and y.
  282.  
  283.       Return value:  Returns +1 if x>y, returns 0 if x=y, returns -1 if x<y.
  284.  
  285.       Restrictions:  None
  286.  
  287.       See also:      fcomp
  288.  
  289.  
  290.  
  291.       Function:      void convert(n,x)
  292.                           convert     
  293.                      int n;
  294.                      big x;
  295.  
  296.       Module:        bncore.c
  297.  
  298.       Description:   Convert an integer number to big number format.
  299.  
  300.       Parameters:    An integer n and a big number x.
  301.  
  302.       Return value:  None
  303.  
  304.       Restrictions:  None
  305.  
  306.       See also:      fconv, lconv, dconv
  307.  
  308.  
  309.  
  310.       Function:      void copy(x,y)
  311.                           copy     
  312.                      flash x,y;
  313.  
  314.       Module:        bncore.c
  315.  
  316.       Description:   Copies a big or flash number to another.
  317.  
  318.       Parameters:    Two big or flash numbers x and y. On exit y=x. Note
  319.                      that if x and y are the same variable, no operation is
  320.                      performed.
  321.  
  322.       Return value:  None
  323.  
  324.       Restrictions:  None
  325.  
  326.       See also:      -
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.       Function:      int cotnum(x,f)
  344.                          cotnum     
  345.                      flash x;
  346.                      FILE *f;
  347.  
  348.       Module:        bnio2.c
  349.  
  350.       Description:   Output a big or flash number to the screen or to a file,
  351.                      using as number base the value currently assigned to the
  352.                      global variable IOBASE. A flash number will be converted
  353.                      to radix-point representation if the global variable
  354.                      POINT=ON. Otherwise it will be output as a fraction. If
  355.                      the global variable WRAP=ON, numbers too large to be
  356.                      represented on one line are 'wrapped around' onto the
  357.                      next line.
  358.  
  359.       Parameters:    A big/flash number x and a file descriptor f. If f is
  360.                      stdout then output will be to the screen, otherwise to
  361.                      the file opened with descriptor f.
  362.  
  363.       Return value:  Number of output characters.
  364.  
  365.       Restrictions:  None
  366.  
  367.       See also:      innum, cinnum, otnum.
  368.  
  369.       Example:       IOBASE=256
  370.                      cotnum(x,fp);
  371.  
  372.                      This outputs x (in pure binary) as a byte array, to the
  373.                      file associated with fp.
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.       Function:      void dconv(d,x)
  410.                           dconv     
  411.                      double d;
  412.                      flash x;
  413.  
  414.       Module:        bnflash.c
  415.  
  416.       Description:   Converts a double to flash format.
  417.  
  418.       Parameters:    A double d and a flash variable x. On exit x will
  419.                      contain the flash equivalent of d.
  420.  
  421.       Return value:  None
  422.  
  423.       Restrictions:  None
  424.  
  425.       See also:      fdsize, lconv, convert,fconv
  426.  
  427.  
  428.  
  429.       Function:      void decr(x,n,z)
  430.                           decr       
  431.                      big x,z;
  432.                      int n;
  433.  
  434.       Module:        bnarth0.c
  435.  
  436.       Description:   Decrement a big number by an integer amount.
  437.  
  438.       Parameters:    Big numbers x and z, and integer n. On exit z=x-n.
  439.  
  440.       Return value:  None
  441.  
  442.       Restrictions:  None
  443.  
  444.       See also:      add, subtract, incr.
  445.  
  446.       Example:       decr(x,2,x);  /* This decrements x by 2. */
  447.  
  448.  
  449.  
  450.       Function:      void denom(x,y)
  451.                           denom     
  452.                      flash x;
  453.                      big y;
  454.  
  455.       Module:        bncore.c
  456.  
  457.       Description:   Extract the denominator of a flash number into a big number
  458.  
  459.       Parameters:    A flash number x and a big number y. On exit y will contain
  460.                      the denominator of x.
  461.  
  462.       Return value:  None
  463.  
  464.       Restrictions:  None
  465.  
  466.       See also:      numer, fpack.
  467.  
  468.  
  469.  
  470.  
  471.  
  472.  
  473.  
  474.  
  475.  
  476.  
  477.  
  478.       Function:      void divide(x,y,z)
  479.                           divide       
  480.                      big x,y,z;
  481.  
  482.       Module:        bnarth2.c
  483.  
  484.       Description:   Divides one big number by another.
  485.  
  486.       Parameters:    Three big numbers x, y and z. On exit z=x/y; x=x mod y.
  487.                      The quotient only is returned if x and z are the same, the
  488.                      remainder only if y and z are the same.
  489.  
  490.       Return value:  None
  491.  
  492.       Restrictions:  Parameters x and y must be different, and y must be
  493.                      non-zero.
  494.  
  495.       See also:      multiply, mad
  496.  
  497.       Example:       divide(x,y,y);
  498.  
  499.                      This sets x equal to the remainder when x is divided by y.
  500.                      The quotient is not returned.
  501.  
  502.  
  503.  
  504.       Function:      void expb2(x,n)
  505.                           expb2     
  506.                      big x;
  507.                      int n;
  508.  
  509.       Module:        bnarth3.c
  510.  
  511.       Description:   Calculates 2 to the power of an integer.
  512.  
  513.       Parameters:    A big number x and an integer n. On exit x=2^n.
  514.  
  515.       Return value:  None
  516.  
  517.       Restrictions:  None
  518.  
  519.       See also:      logb2
  520.  
  521.       Example:       expb2(x,216091);
  522.                      decr(x,1,x);
  523.                      cotnum(x,stdout);
  524.  
  525.                      This calculates and prints out the largest known prime
  526.                      number (on a true 32-bit computer).
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.       Function:      int exsign(x)
  547.                          exsign   
  548.                      flash x;
  549.  
  550.       Module:        bncore.c
  551.  
  552.       Description:   Extracts the sign of a big/flash number.
  553.  
  554.       Parameters:    A big/flash number x.
  555.  
  556.       Return value:  The sign of x, i.e. -1 if x is negative, +1 if x is zero
  557.                      or positive.
  558.  
  559.       Restrictions:  None
  560.  
  561.       See also:      insign
  562.  
  563.  
  564.  
  565.       Function:      void facos(x,y)
  566.                           facos     
  567.                      flash x,y;
  568.  
  569.       Module:        bnflsh3.c
  570.  
  571.       Description:   Calculates arc-cosine of a flash number, using fasin.
  572.  
  573.       Parameters:    Two flash numbers x and y. On exit y=acos(x).
  574.  
  575.       Return value:  None
  576.  
  577.       Restrictions:  |x| must be less than or equal to 1.
  578.  
  579.       See also:      fatan, fasin
  580.  
  581.  
  582.  
  583.       Function:      void facosh(x,y)
  584.                           facosh     
  585.                      flash x,y;
  586.  
  587.       Module:        bnflsh4.c
  588.  
  589.       Description:   Calculates hyperbolic arc-cosine of a flash number.
  590.  
  591.       Parameters:    Two flash numbers x and y. On exit y=acosh(x).
  592.  
  593.       Return value:  None
  594.  
  595.       Restrictions:  |x| must be greater than or equal to 1.
  596.  
  597.       See also:      fatanh, fasinh
  598.  
  599.  
  600.  
  601.  
  602.  
  603.  
  604.  
  605.  
  606.  
  607.  
  608.  
  609.  
  610.  
  611.  
  612.  
  613.  
  614.  
  615.       Function:      void fadd(x,y,z)
  616.                           fadd       
  617.                      flash x,y,z;
  618.  
  619.       Module:        bnflash.c
  620.  
  621.       Description:   Add two flash numbers.
  622.  
  623.       Parameters:    Three flash numbers x, y and z. On exit z=x+y.
  624.  
  625.       Return value:  None
  626.  
  627.       Restrictions:  None
  628.  
  629.       See also:      fsub, fincr
  630.  
  631.  
  632.  
  633.       Function:      void fasin(x,y)
  634.                           fasin     
  635.                      flash x,y;
  636.  
  637.       Module:        bnflsh3.c
  638.  
  639.       Description:   Calculates arc-sin of a flash number, using fatan.
  640.  
  641.       Parameters:    Two flash numbers x and y. On exit y=asin(x).
  642.  
  643.       Return value:  None
  644.  
  645.       Restrictions:  |x| must be less than or equal to 1.
  646.  
  647.       See also:      facos, fatan
  648.  
  649.  
  650.  
  651.       Function:      void fasinh(x,y)
  652.                           fasinh     
  653.                      flash x,y;
  654.  
  655.       Module:        bnflsh4.c
  656.  
  657.       Description:   Calculates hyperbolic arc-sin of a flash number.
  658.  
  659.       Parameters:    Two flash numbers x and y. On exit y=asinh(x).
  660.  
  661.       Return value:  None
  662.  
  663.       Restrictions:  None
  664.  
  665.       See also:      facosh, fatanh
  666.  
  667.  
  668.  
  669.  
  670.  
  671.  
  672.  
  673.  
  674.  
  675.  
  676.  
  677.  
  678.  
  679.  
  680.  
  681.  
  682.  
  683.  
  684.       Function:      void fatan(x,y)
  685.                           fatan     
  686.                      flash x,y;
  687.  
  688.       Module:        bnflsh3.c
  689.  
  690.       Desciption:    Calculates the arc-tangent of a flash number, using
  691.                      O(n^2.5) method based on Newton's iteration.
  692.  
  693.       Parameters:    Two flash numbers x and y. On exit y=atan(x).
  694.  
  695.       Return value:  None
  696.  
  697.       Restrictions:  None
  698.  
  699.       See also:      fasin, facos
  700.  
  701.  
  702.       Function:      void fatanh(x,y)
  703.                           fatanh     
  704.                      flash x,y;
  705.  
  706.       Module:        bnflsh4.c
  707.  
  708.       Desciption:    Calculates the hyperbolic arc-tangent of a flash number.
  709.  
  710.       Parameters:    Two flash numbers x and y. On exit y=atanh(x).
  711.  
  712.       Return value:  None
  713.  
  714.       Restrictions:  x.x  must be less than 1
  715.  
  716.       See also:      fasinh, facosh
  717.  
  718.  
  719.  
  720.       Function:      int fcomp(x,y)
  721.                          fcomp     
  722.                      flash x,y;
  723.  
  724.       Module:        bnflash.c
  725.  
  726.       Description:   Compare two flash numbers.
  727.  
  728.       Parameters:    Two flash numbers x and y.
  729.  
  730.       Return value:  Returns -1 if y>x, +1 if x>y and 0 if x=y.
  731.  
  732.       Restrictions:  None
  733.  
  734.       See also:      compare
  735.  
  736.  
  737.  
  738.  
  739.  
  740.  
  741.  
  742.  
  743.  
  744.  
  745.  
  746.  
  747.  
  748.  
  749.  
  750.  
  751.  
  752.  
  753.       Function:      void fconv(n,d,x)
  754.                           fconv       
  755.                      int n,d;
  756.                      flash x;
  757.  
  758.       Module:        bnflash.c
  759.  
  760.       Description:   Convert a simple fraction to flash format.
  761.  
  762.       Parameters:    Integers n and d, and a flash number x. On exit x={n/d}
  763.  
  764.       Return value:  None
  765.  
  766.       Restrictions:  None
  767.  
  768.       See also:      convert, lconv, dconv
  769.  
  770.  
  771.  
  772.       Function:      void fcos(x,y)
  773.                           fcos     
  774.                      flash x,y;
  775.  
  776.       Module:        bnflsh3.c
  777.  
  778.       Description:   Calculates cosine of a given flash angle, using ftan.
  779.  
  780.       Parameters:    Two flash numbers x and y. On exit y=cos(x).
  781.  
  782.       Return value:  None
  783.  
  784.       Restrictions:  None
  785.  
  786.       See also:      fsin, ftan
  787.  
  788.  
  789.       Function:      void fcosh(x,y)
  790.                           fcosh     
  791.                      flash x,y;
  792.  
  793.       Module:        bnflsh4.c
  794.  
  795.       Description:   Calculates hyperbolic cosine of a given flash angle.
  796.  
  797.       Parameters:    Two flash numbers x and y. On exit y=cosh(x).
  798.  
  799.       Return value:  None
  800.  
  801.       Restrictions:  None
  802.  
  803.       See also:      fsinh, ftanh
  804.  
  805.  
  806.  
  807.  
  808.  
  809.  
  810.  
  811.  
  812.  
  813.  
  814.  
  815.  
  816.  
  817.  
  818.  
  819.  
  820.  
  821.  
  822.       Function:      void fdiv(x,y,z)
  823.                           fdiv       
  824.                      flash x,y,z;
  825.  
  826.       Module:        bnflash.c
  827.  
  828.       Description:   Divides two flash numbers.
  829.  
  830.       Parameters:    Three big numbers x,y and z. on exit z=x/y.
  831.  
  832.       Return value:  None
  833.  
  834.       Restrictions:  None
  835.  
  836.       See also:      fmul, fpmul
  837.  
  838.  
  839.  
  840.       Function:      double fdsize(x)
  841.                             fdsize   
  842.                      flash x;
  843.  
  844.       Module:        bndouble.c
  845.  
  846.       Description:   Converts a flash number to double format.
  847.  
  848.       Parameters:    A flash number x.
  849.  
  850.       Return value:  The value of the parameter x as a double.
  851.  
  852.       Restrictions:  The value of x must be less than BIGGEST. See mirdef.h
  853.  
  854.       See also:      dconv
  855.  
  856.  
  857.  
  858.       Function:      void fexp(x,y)
  859.                           fexp     
  860.                      flash x,y;
  861.  
  862.       Module:        bnflsh2.c
  863.  
  864.       Description:   Calculates the exponential of a flash number using
  865.                      O(n^2.5) method.
  866.  
  867.       Parameters:    Two flash numbers x and y. On exit y=exp(x).
  868.  
  869.       Return value:  None
  870.  
  871.       Restrictions:  None
  872.  
  873.       See also:      flog, fpowf
  874.  
  875.  
  876.  
  877.  
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.       Function:      void fincr(x,n,d,y)
  892.                           fincr         
  893.                      big x,y;
  894.                      int n,d;
  895.  
  896.       Module:        bnflash.c
  897.  
  898.       Description:   Add a simple fraction to a flash number.
  899.  
  900.       Parameters:    Two flash numbers x and y, and two integers n and d.
  901.                      On exit y=x+{n/d}.
  902.  
  903.       Return value:  None
  904.  
  905.       Restrictions:  None
  906.  
  907.       See also:      fadd, fsub
  908.  
  909.       Example:       fincr(x,-2,3,x);
  910.                      This subtracts two-thirds from the value of x.
  911.  
  912.  
  913.       Function:      void flog(x,y)
  914.                           flog     
  915.                      flash x,y;
  916.  
  917.       Module:        bnflsh2.c
  918.  
  919.       Description:   Calculates the natural log of a flash number using
  920.                      O(n^2.5) method.
  921.  
  922.       Parameters:    Two flash numbers x and y. On exit y=log(x).
  923.  
  924.       Return value:  None
  925.  
  926.       Restrictions:  None
  927.  
  928.       See also:      fexp, fpowf
  929.  
  930.  
  931.       Function:      void flop(x,y,op,z)
  932.                           flop          
  933.                      flash x,y,z;
  934.                      int *op;
  935.  
  936.       Module:        bnflash.c
  937.  
  938.       Description:   Perform primitive flash operation. Used internally.
  939.  
  940.       Parameters:    Three flash numbers x,y and z. On exit z=Fn(x,y),
  941.                      where the function performed depends on the
  942.                      parameter op. See source listing comments for more
  943.                      details.
  944.  
  945.       Restrictions:  None
  946.  
  947.       Return value:  None
  948.  
  949.       See also:      fadd, fsub, fmul, fdiv
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.       Function:      void fmul(x,y,z)
  962.                           fmul       
  963.                      flash x,y,z;
  964.  
  965.       Module:        bnflash.c
  966.  
  967.       Description:   Multiply two flash numbers.
  968.  
  969.       Parameters:    Three flash numbers x,y and z. On exit z=x*y.
  970.  
  971.       Return value:  None
  972.  
  973.       Restrictions:  None
  974.  
  975.       See also:      fpmul, fdiv
  976.  
  977.  
  978.       Function:      void fpack(n,d,x)
  979.                           fpack       
  980.                      flash x;
  981.                      big n,d;
  982.  
  983.       Module:        bncore.c
  984.  
  985.       Description:   Forms a flash number from big numerator and denominator.
  986.  
  987.       Parameters:    A flash number x and two big numbers n and d. On exit
  988.                      x={n/d}.
  989.  
  990.       Return value:  None
  991.  
  992.       Restrictions:  The denominator must be non-zero. Flash variable x and big
  993.                      variable d must be distinct. The resulting flash variable
  994.                      must not be too big for the representation.
  995.  
  996.       See also:      numer, denom.
  997.  
  998.  
  999.       Function:      void fpi(x)
  1000.                           fpi   
  1001.                      flash x;
  1002.  
  1003.       Module:        bnpi.c
  1004.  
  1005.       Description:   Calculates pi using Guass-Legendre O(n².log(n)) method.
  1006.                      Note that on subsequent calls to this routine, pi is
  1007.                      immediately available, as it is stored internally.
  1008.  
  1009.       Parameters:    A flash number x. On exit x=pi.
  1010.  
  1011.       Return value:  None
  1012.  
  1013.       Restrictions:  None.
  1014.  
  1015.       See also:      fsin, fcos, ftan
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029.       Function:      void fpower(x,n,y)
  1030.                           fpower       
  1031.                      flash x,y;
  1032.                      int n;
  1033.  
  1034.       Module:        bnflsh1.c
  1035.  
  1036.       Description:   Raises a flash number to an integer power.
  1037.  
  1038.       Parameters:    Flash variables x and y, and an integer n. On exit
  1039.                      y=x^n.
  1040.  
  1041.       Return value:  None
  1042.  
  1043.       Restrictions:  None
  1044.  
  1045.       See also:      froot
  1046.  
  1047.  
  1048.       Function:      void fpmul(x,n,d,y)
  1049.                           fpmul         
  1050.                      flash x,y;
  1051.                      int n,d;
  1052.  
  1053.       Module:        bnflash.c
  1054.  
  1055.       Description:   Multiplies a flash number by a simple fraction.
  1056.  
  1057.       Parameters:    Two flash numbers x and y, and two integers n and d.
  1058.                      On exit y=x.{n/d}
  1059.  
  1060.       Return value:  None
  1061.  
  1062.       Restrictions:  None
  1063.  
  1064.       See also:      fmul, fdiv
  1065.  
  1066.  
  1067.       Function:      void fpowf(x,y,z)
  1068.                           fpowf       
  1069.                      flash x,y,z;
  1070.  
  1071.       Module:        bnflsh2.c
  1072.  
  1073.       Description:   Raises a flash number to a flash power.
  1074.  
  1075.       Parameters:    Three flash numbers x, y and z. On exit z=x^y
  1076.  
  1077.       Return value:  None
  1078.  
  1079.       Restrictions:  None
  1080.  
  1081.       See also:      fexp, flog
  1082.  
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.       Function:      void frand(x)
  1099.                           frand   
  1100.                      flash x;
  1101.  
  1102.       Module:        bnrand.c
  1103.  
  1104.       Description:   Generates a random flash number.
  1105.  
  1106.       Parameters:    A big number x. On exit x contains a flash random number
  1107.                      in the range 0<x<1.
  1108.  
  1109.       Return value:  None
  1110.  
  1111.       Restrictions:  None
  1112.  
  1113.       See also:      bigrand, bigdig
  1114.  
  1115.  
  1116.       Function:      void frecip(x,y)
  1117.                           frecip     
  1118.                      flash x,y;
  1119.  
  1120.       Module:        bnflash.c
  1121.  
  1122.       Description:   Calculates reciprocal of a flash number.
  1123.  
  1124.       Parameters:    Two flash numbers x and y. On exit y=1/x.
  1125.  
  1126.       Return value:  None
  1127.  
  1128.       Restrictions:  None
  1129.  
  1130.       See also:      fdiv, fmul
  1131.  
  1132.  
  1133.       Function:      bool froot(x,m,y)
  1134.                           froot       
  1135.                      flash x,y;
  1136.                      int m;
  1137.  
  1138.       Module:        bnflsh1.c
  1139.  
  1140.       Description:   Calculates m-th root of a flash number using Newton's
  1141.                      O(n²) method.
  1142.  
  1143.       Parameters:    Flash numbers x and y, and an integer m. On exit y is
  1144.                      the m-th root of x.
  1145.  
  1146.       Return value:  TRUE for exact root, otherwise FALSE
  1147.  
  1148.       Restrictions:  None
  1149.  
  1150.       See also:      fpower
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167.       Function:      void fsin(x,y)
  1168.                           fsin     
  1169.                      flash x,y;
  1170.  
  1171.       Module:        bnflsh3.c
  1172.  
  1173.       Description:   Calculates sine of a given flash angle. Uses ftan.
  1174.  
  1175.       Parameters:    Two flash numbers x and y. On exit y=sin(x).
  1176.  
  1177.       Return value:  None
  1178.  
  1179.       Restrictions:  None
  1180.  
  1181.       See also:      fcos, ftan
  1182.  
  1183.  
  1184.       Function:      void fsinh(x,y)
  1185.                           fsinh     
  1186.                      flash x,y;
  1187.  
  1188.       Module:        bnflsh4.c
  1189.  
  1190.       Description:   Calculates hyperbolic sine of a given flash angle.
  1191.  
  1192.       Parameters:    Two flash numbers x and y. On exit y=sinh(x).
  1193.  
  1194.       Return value:  None
  1195.  
  1196.       Restrictions:  None
  1197.  
  1198.       See also:      fcosh, ftanh
  1199.  
  1200.  
  1201.       Function:      void fsub(x,y,z)
  1202.                           fsub       
  1203.                      flash x,y,z;
  1204.  
  1205.       Module:        bnflash.c
  1206.  
  1207.       Description:   Subtract two flash numbers.
  1208.  
  1209.       Parameters:    Three flash numbers x,y and z. On exit z=x-y.
  1210.  
  1211.       Return value:  None
  1212.  
  1213.       Restrictions:  None
  1214.  
  1215.       See also:      fadd, fincr
  1216.  
  1217.  
  1218.  
  1219.  
  1220.  
  1221.  
  1222.  
  1223.  
  1224.  
  1225.  
  1226.  
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236.       Function:      void ftan(x,y)
  1237.                           ftan     
  1238.                      flash x,y;
  1239.  
  1240.       Module:        bnflsh3.c
  1241.  
  1242.       Description:   Calculates the tan of a given flash angle, using an
  1243.                      O(n²√n) method.
  1244.  
  1245.       Parameters:    Two flash numbers x and y. On exit y=tan(x).
  1246.  
  1247.       Return value:  None
  1248.  
  1249.       Restrictions:  None
  1250.  
  1251.       See also:      fsin, fcos
  1252.  
  1253.  
  1254.       Function:      void ftanh(x,y)
  1255.                           ftanh     
  1256.                      flash x,y;
  1257.  
  1258.       Module:        bnflsh4.c
  1259.  
  1260.       Description:   Calculates the hyperbolic tan of a given flash angle.
  1261.  
  1262.       Parameters:    Two flash numbers x and y. On exit y=tanh(x).
  1263.  
  1264.       Return value:  None
  1265.  
  1266.       Restrictions:  None
  1267.  
  1268.       See also:      fsinh, fcosh
  1269.  
  1270.  
  1271.       Function:      void ftrunc(x,y,z)
  1272.                           ftrunc       
  1273.                      flash x,z;
  1274.                      big y;
  1275.  
  1276.       Module:        bnflash.c
  1277.  
  1278.       Description:   Seperates a flash number to a big number and a flash
  1279.                      remainder.
  1280.  
  1281.       Parameters:    Flash numbers x and z, and a big number y.
  1282.                      On exit y=int(x) and z = x-y (the fractional remainder).
  1283.                      if y is the same as z, only int(x) is returned.
  1284.  
  1285.       Return value:  None
  1286.  
  1287.       Restrictions:  None
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.  
  1296.  
  1297.  
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.       Function:      int gcd(x,y,z)
  1306.                          gcd       
  1307.                      big x,y,z;
  1308.  
  1309.       Module:        bngcd.c
  1310.  
  1311.       Description:   Calculates the Greatest Common Divisor of two big numbers.
  1312.  
  1313.       Parameters:    Three big numbers x, y and z. On exit z=gcd(x,y)
  1314.  
  1315.       Return value:  GCD as integer, if possible, otherwise TOOBIG
  1316.  
  1317.       Restrictions:  None
  1318.  
  1319.       See also:      xgcd, round
  1320.  
  1321.  
  1322.       Function:      int getdig(x,i)
  1323.                          getdig     
  1324.                      big x;
  1325.                      int i;
  1326.  
  1327.       Module:        bncore.c
  1328.  
  1329.       Description:   Extracts a digit from a big number.
  1330.  
  1331.       Parameters:    A big number x, and the required digit i.
  1332.  
  1333.       Return value:  The value of the requested digit.
  1334.  
  1335.       Restrictions:  Returns rubbish if required digit does not exist.
  1336.  
  1337.       See also:      putdig, numdig.
  1338.  
  1339.  
  1340.  
  1341.       Function:      int *gprime(n)
  1342.                          *gprime   
  1343.                      int n;
  1344.  
  1345.       Module:        bnsmall.c
  1346.  
  1347.       Description:   Generates an array of all prime numbers up to a certain
  1348.                      limit, terminated by zero.
  1349.  
  1350.       Parameters:    A positive integer n indicating the maximum prime
  1351.                      number to be generated, or a negative integer
  1352.                      indicating that (-n) primes are to be generated.
  1353.  
  1354.       Return value:  A pointer to the prime number array.
  1355.  
  1356.       Restrictions:  None
  1357.  
  1358.       See also:      -
  1359.  
  1360.  
  1361.  
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.       Function:      int igcd(x,y)
  1375.                          igcd     
  1376.                      int x,y;
  1377.  
  1378.       Module:        bncore.c
  1379.  
  1380.       Description:   Calculates the Greatest Common Divisor of two integers
  1381.                      using Euclids Method.
  1382.  
  1383.       Parameters:    Two integers x and y
  1384.  
  1385.       Return value:  The GCD of x and y
  1386.  
  1387.       See also:      gcd
  1388.  
  1389.  
  1390.  
  1391.       Function:      void incr(x,n,z)
  1392.                           incr       
  1393.                      big x,z;
  1394.                      int n;
  1395.  
  1396.       Module:        bnarth0.c
  1397.  
  1398.       Description:   Increment a big variable.
  1399.  
  1400.       Parameters:    Big numbers x and z, and an integer n. On exit z=x+n.
  1401.  
  1402.       Return value:  None
  1403.  
  1404.       Restrictions:  None
  1405.  
  1406.       See also:      add, subtract, decr.
  1407.  
  1408.  
  1409.  
  1410.  
  1411.  
  1412.  
  1413.  
  1414.  
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.       Function:      int innum(x,f)
  1444.                          innum     
  1445.                      flash x;
  1446.                      FILE *f;
  1447.  
  1448.       Module:        bnio1.c
  1449.  
  1450.       Description:   Inputs a big or flash number from a file, the keyboard
  1451.                      or a string. Flash numbers can be entered using either
  1452.                      a slash '/' to indicate numerator and denominator, or
  1453.                      with a radix point.
  1454.  
  1455.       Parameters:    A big/flash number x and a file descriptor f. For input
  1456.                      from the keyboard specify f as stdin, otherwise as the
  1457.                      descriptor of some other opened file. To input from a
  1458.                      string, copy the string to the global character array
  1459.                      IBUFF before calling innum. In this case the file
  1460.                      descriptor will be ignored, and input taken directly from
  1461.                      IBUFF.
  1462.  
  1463.       Return value:  The number of characters input.
  1464.  
  1465.       Restrictions:  The number base specified in mirsys must be less than
  1466.                      or equal to 256. If not use cinnum instead.
  1467.  
  1468.       See also:      otnum, cinnum, cotnum.
  1469.  
  1470.  
  1471.  
  1472.  
  1473.       Function:      void insign(s,x)
  1474.                           insign     
  1475.                      int s;
  1476.                      flash x;
  1477.  
  1478.       Module:        bncore.c
  1479.  
  1480.       Description:   Forces a big/flash number to a particular sign.
  1481.  
  1482.       Parameters:    A big/flash number x, and the sign s that it is to take.
  1483.                      On exit x=s*abs(x).
  1484.  
  1485.       Return value:  None
  1486.  
  1487.       Restrictions:  None
  1488.  
  1489.       See also:      exsign.
  1490.  
  1491.       Example:       insign(PLUS,x);  /* force x to be positive */
  1492.  
  1493.  
  1494.  
  1495.  
  1496.  
  1497.  
  1498.  
  1499.  
  1500.  
  1501.  
  1502.  
  1503.  
  1504.  
  1505.  
  1506.  
  1507.  
  1508.  
  1509.  
  1510.       Function:      int inverse(x,y)
  1511.                          inverse     
  1512.                      int x,y;
  1513.  
  1514.       Module:        bnsmall.c
  1515.  
  1516.       Description:   Calculates the inverse of an integer modulus a co-
  1517.                      prime integer
  1518.  
  1519.       Parameters:    An integer x and a co-prime integer y
  1520.  
  1521.       Return value:  1/x mod y
  1522.  
  1523.       Restrictions:  Return value is unpredictable if x and y are not co-
  1524.                      prime
  1525.  
  1526.       See also:      igcd, sqrmp
  1527.  
  1528.  
  1529.  
  1530.       Function:      void irand(seed)
  1531.                           irand      
  1532.                      long seed;
  1533.  
  1534.       Module:        bncore.c
  1535.  
  1536.       Description:   Initializes random number system. Uses Knuth's subtractive
  1537.                      method. Long integer types are used internally to yield a
  1538.                      generator with maximum period.
  1539.  
  1540.       Parameters:    A long integer seed, which is used to start off the
  1541.                      random number generator.
  1542.  
  1543.       Return value:  None
  1544.  
  1545.       Restrictions:  None
  1546.  
  1547.       See also:      brand, bigrand, bigdig, frand.
  1548.  
  1549.  
  1550.       Function:      void lconv(ln,x)
  1551.                           lconv      
  1552.                      long n;
  1553.                      big x;
  1554.  
  1555.       Module:        bncore.c
  1556.  
  1557.       Description:   Converts a long integer to big number format
  1558.  
  1559.       Parameters:    A long integer ln and a big number x
  1560.  
  1561.       Return value:  None
  1562.  
  1563.       Restrictions:  None
  1564.  
  1565.       See also:      convert, fconv, dconv
  1566.  
  1567.  
  1568.  
  1569.  
  1570.  
  1571.  
  1572.  
  1573.  
  1574.  
  1575.  
  1576.  
  1577.  
  1578.  
  1579.       Function:      int logb2(x)
  1580.                          logb2   
  1581.                      big x;
  1582.  
  1583.       Module:        bnarth3.c
  1584.  
  1585.       Description:   Calculates the approximate integer log to the base 2 of
  1586.                      a big number (in fact the number of bits in it.)
  1587.  
  1588.       Parameters:    A big number x.
  1589.  
  1590.       Return value:  Number of bits in x
  1591.  
  1592.       Restrictions:  None
  1593.  
  1594.       See also:      expb2
  1595.  
  1596.  
  1597.  
  1598.       Function:      void mad(x,y,z,w,q,r)
  1599.                           mad             
  1600.                      big x,y,z,w,q,r;
  1601.  
  1602.       Module:        bnarth2.c
  1603.  
  1604.       Description:   Multiply add and divide big numbers. The initial product
  1605.                      is stored in a double-length internal variable to avoid
  1606.                      the possibility of overflow at this stage.
  1607.  
  1608.       Parameters:    Six big numbers x,y,z,w,q and r. On exit q=(x*y+z)/w and
  1609.                      r contains the remainder. If w and q are not distinct
  1610.                      variables then only the remainder is returned; if q and r
  1611.                      are not distinct then only the quotient is returned. The
  1612.                      addition of z is not done if x and z (or y and z) are the
  1613.                      same.
  1614.  
  1615.       Return value:  None
  1616.  
  1617.       Restrictions:  Parameters w and r must be distinct. The value of w must
  1618.                      not be zero.
  1619.  
  1620.       See also:      multiply, divide.
  1621.  
  1622.       Example:       mad(x,x,x,w,x,x);
  1623.  
  1624.                      This sets x=(x*x)/w. The remainder is not returned.
  1625.  
  1626.  
  1627.  
  1628.  
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.       Function:      void mirsys(nd,nb)
  1648.                           mirsys       
  1649.                      int nd,nb;
  1650.  
  1651.       Module:        bncore.c
  1652.  
  1653.       Description:   Initialize the MIRACL system as described below. Must
  1654.                      be called before attempting to use any other MIRACL
  1655.                      routines.
  1656.  
  1657.                      (1) The error tracing mechanism is initialised.
  1658.  
  1659.                      (2) the number of computer words to use for each
  1660.                          big/flash number is calculated from nd and nb.
  1661.  
  1662.                      (3) Sixteen big work variables (four of them double
  1663.                          length) are initialised.
  1664.  
  1665.                      (4) Certain global variables are given default initial
  1666.                          values.
  1667.  
  1668.                      (5) The random number generator is started by calling
  1669.                          irand(0L).
  1670.  
  1671.       Parameters:    The number of digits nd to use for each big/flash
  1672.                      variable and the number base nb. If nd is negative it
  1673.                      is taken as indicating the size of big/flash numbers
  1674.                      in 8-bit bytes.
  1675.  
  1676.       Return value:  None
  1677.  
  1678.       Restrictions:  The number base nb must be greater than 1 and less
  1679.                      than or equal to MAXBASE. The number of digits nd must
  1680.                      be less than a certain maximum, depending on the value
  1681.                      of BTS. (See mirdef.h).
  1682.  
  1683.       See also:      irand, mirvar.
  1684.  
  1685.  
  1686.       Example:       mirsys(500,10);
  1687.  
  1688.                      This initializes the MIRACL system to use 500 decimal
  1689.                      digits for each big or flash number.
  1690.  
  1691.  
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701.  
  1702.  
  1703.  
  1704.  
  1705.  
  1706.  
  1707.  
  1708.  
  1709.  
  1710.  
  1711.  
  1712.  
  1713.  
  1714.       Function:      flash mirvar(iv)
  1715.                            mirvar    
  1716.                      int iv;
  1717.  
  1718.       Module:        bncore.c
  1719.  
  1720.       Description:   Initialises a big/flash variable by reserving a suitable
  1721.                      number of memory locations for it.
  1722.  
  1723.       Parameters:    An integer initial value for the big/flash number.
  1724.  
  1725.       Return Value:  A pointer to the reserved locations.
  1726.  
  1727.       Restrictions:  None
  1728.  
  1729.       See also:      mirsys
  1730.  
  1731.       Example:       flash x;
  1732.                      x=mirvar(1);
  1733.  
  1734.                      Creates a flash variable x=1.
  1735.  
  1736.  
  1737.  
  1738.       Function:      void multiply(x,y,z)
  1739.                           multiply       
  1740.                      big x,y,z;
  1741.  
  1742.       Module:        bnarth2.c
  1743.  
  1744.       Description:   Multiplies two big numbers
  1745.  
  1746.       Parameters:    Three big numbers x,y and z. On exit z=x.y
  1747.  
  1748.       Return value:  None
  1749.  
  1750.       Restrictions:  None
  1751.  
  1752.       See also:      divide, mad
  1753.  
  1754.  
  1755.  
  1756.       Function:      void negate(x,y)
  1757.                           negate     
  1758.                      flash x,y;
  1759.  
  1760.       Module:        bncore.c
  1761.  
  1762.       Description:   Negates a big/flash number.
  1763.  
  1764.       Parameters:    Two big/flash numbers x and y. On exit y=-x.
  1765.  
  1766.       Return value:  None
  1767.  
  1768.       Restrictions:  None. Note that negate(x,x) is valid and sets x=-x.
  1769.  
  1770.       See also:      absol.
  1771.  
  1772.  
  1773.  
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.  
  1781.  
  1782.  
  1783.       Function:      int numdig(x)
  1784.                          numdig   
  1785.                      big x;
  1786.  
  1787.       Module:        bncore.c
  1788.  
  1789.       Description:   Calculates the number of digits in a big number.
  1790.  
  1791.       Parameters:    A big number x.
  1792.  
  1793.       Return value:  The number of digits in x.
  1794.  
  1795.       Restrictions:  None
  1796.  
  1797.       See also:      getdig, putdig.
  1798.  
  1799.  
  1800.  
  1801.       Function:      void numer(x,y)
  1802.                           numer     
  1803.                      flash x;
  1804.                      big y;
  1805.  
  1806.       Module:        bncore.c
  1807.  
  1808.       Description:   Extract the numerator of a flash number.
  1809.  
  1810.       Parameters:    A flash number x and a big number y. On exit y will contain
  1811.                      the numerator of x.
  1812.  
  1813.       Return value:  None
  1814.  
  1815.       Restrictions:  None
  1816.  
  1817.       See also:      denom, fpack.
  1818.  
  1819.  
  1820.       Function:      void nxprime(w,x)
  1821.                           nxprime     
  1822.                      big w,x;
  1823.  
  1824.       Module:        bnprime.c
  1825.  
  1826.       Description:   Find next prime number.
  1827.  
  1828.       Parameters:    Two big numbers w and x. On exit x contains the next prime
  1829.                      number greater than w.
  1830.  
  1831.       Return value:  None
  1832.  
  1833.       Restrictions:  None
  1834.  
  1835.       See also:      prime
  1836.  
  1837.  
  1838.  
  1839.  
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.       Function:      int otnum(x,f)
  1853.                          otnum     
  1854.                      flash x;
  1855.                      FILE *f;
  1856.  
  1857.       Module:        bnio1.c
  1858.  
  1859.       Description:   Output a big or flash number to the screen or to a file.
  1860.                      If STROUT=TRUE output is redirected to the global string
  1861.                      OBUFF[]. A flash number will be converted to radix-point
  1862.                      representation if the global variable POINT=ON. Otherwise
  1863.                      it will be output as a fraction. If the global variable
  1864.                      WRAP=ON numbers too large to be represented on one line
  1865.                      are 'wrapped around' onto the next line.
  1866.  
  1867.       Parameters:    A big/flash number x and a file descriptor f. If f is
  1868.                      stdout then output will be to the screen, otherwise to
  1869.                      the file opened with descriptor f.
  1870.  
  1871.       Return value:  Number of output characters.
  1872.  
  1873.       Restrictions:  The number base specified in mirsys must be less than or
  1874.                      equal to 256. If not, use cotnum instead.
  1875.  
  1876.       See also:      innum, cinnum, cotnum.
  1877.  
  1878.  
  1879.  
  1880.       Function:      void power(x,n,z,w)
  1881.                           power         
  1882.                      int n;
  1883.                      big x,z,w;
  1884.  
  1885.       Module:        bnarth3.c
  1886.  
  1887.       Description:   Raise a big number to an integer power.
  1888.  
  1889.       Parameters:    Two big numbers x and z, and an integer n. On exit w=x^n
  1890.                      If w and z are distinct, then w=x^n mod z
  1891.  
  1892.       Return value:  None.
  1893.  
  1894.       Restrictions:  The value of n must be positive
  1895.  
  1896.       See also:      powmod, root
  1897.  
  1898.  
  1899.  
  1900.  
  1901.  
  1902.  
  1903.  
  1904.  
  1905.  
  1906.  
  1907.  
  1908.  
  1909.  
  1910.  
  1911.  
  1912.  
  1913.  
  1914.  
  1915.  
  1916.  
  1917.  
  1918.  
  1919.  
  1920.       Function:      void powmod(x,y,z,w)
  1921.                           powmod         
  1922.                      big x,y,z,w;
  1923.  
  1924.       Module:        bnarth3.c
  1925.  
  1926.       Description:   Raise a big number to a big power modulus another big
  1927.                      number.
  1928.  
  1929.       Parameters:    Four big numbers x,y,z and w. On exit w=x^y mod z.
  1930.  
  1931.       Return value:  None
  1932.  
  1933.       Restrictions:  The value of y must be positive. The parameters w and z
  1934.                      must be distinct.
  1935.  
  1936.       See also:      power, root
  1937.  
  1938.  
  1939.  
  1940.       Function:      void premult(x,n,z)
  1941.                           premult       
  1942.                      int n;
  1943.                      big x,z;
  1944.  
  1945.       Module:        bnarth1.c
  1946.  
  1947.       Description:   Multiplies a big number by an integer
  1948.  
  1949.       Parameters:    Two big numbers x and z, and an integer n. On exit z=n.x
  1950.  
  1951.       Return value:  None
  1952.  
  1953.       Restrictions:  None
  1954.  
  1955.       See also:      subdiv
  1956.  
  1957.  
  1958.       Function:      bool prime(x)
  1959.                           prime   
  1960.                      big x;
  1961.  
  1962.       Module:        bnprime.c
  1963.  
  1964.       Description:   Tests whether or not a big number is prime using a
  1965.                      probabilistic primality test. The number is assumed
  1966.                      to be prime if it passes this test NTRY times, where
  1967.                      NTRY is a global variable with a default initialisation
  1968.                      in routine mirsys.
  1969.  
  1970.       Parameters:    A big number x.
  1971.  
  1972.       Return value:  Returns the boolean value TRUE if x is (almost certainly)
  1973.                      prime, otherwise FALSE.
  1974.  
  1975.       Restrictions:  None
  1976.  
  1977.       See also:      nxprime, strongp
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985.  
  1986.  
  1987.  
  1988.  
  1989.       Function:      void putdig(n,x,i)
  1990.                           putdig       
  1991.                      big x;
  1992.                      int i,n;
  1993.  
  1994.       Module:        bncore.c
  1995.  
  1996.       Description:   Set a digit of a big number to a given value
  1997.  
  1998.       Parameters:    A big number x, a digit number i, and its new value n.
  1999.  
  2000.       Return value:  None
  2001.  
  2002.       Restrictions:  The digit indicated must exist.
  2003.  
  2004.       See also:      getdig, numdig.
  2005.  
  2006.  
  2007.       Function:      bool root(x,n,z)
  2008.                           root       
  2009.                      big x,z;
  2010.                      int n;
  2011.  
  2012.       Module:        bnarth3.c
  2013.  
  2014.       Description:   Extracts lower approximation to a root of a big number.
  2015.  
  2016.       Parameters:    Two big numbers x and z, and an integer n. On exit
  2017.                      z=x^(1/n).
  2018.  
  2019.       Return value:  Returns the boolean value TRUE if the root found is exact,
  2020.                      otherwise returns FALSE.
  2021.  
  2022.       Restrictions:  The value of n must be positive. If x is negative, then n
  2023.                      must be odd.
  2024.  
  2025.       See also:      power, powmod
  2026.  
  2027.  
  2028.  
  2029.       Function:      void round(n,d,x)
  2030.                           round       
  2031.                      flash x;
  2032.                      big n,d;
  2033.  
  2034.       Module:        bnround.c
  2035.  
  2036.       Description:   Forms a rounded flash number from big numerator and
  2037.                      denominator. If rounding takes place the global variable
  2038.                      EXACT is set to FALSE. EXACT is initialised to TRUE in
  2039.                      routine mirsys. This routine is used internally by most
  2040.                      of the other flash arithmetic routines.
  2041.  
  2042.       Parameters:    A flash number x and two big numbers n and d. On exit
  2043.                      x=R{n/d}, that is the flash number {n/d} rounded if
  2044.                      necessary to fit the representation.
  2045.  
  2046.       Return value:  None
  2047.  
  2048.       Restrictions:  The denominator must be non-zero.
  2049.  
  2050.       See also:      gcd, xgcd, fpack.
  2051.  
  2052.  
  2053.  
  2054.  
  2055.  
  2056.  
  2057.  
  2058.       Function:      int size(x)
  2059.                          size   
  2060.                      big x;
  2061.  
  2062.       Module:        bncore.c
  2063.  
  2064.       Description:   Tries to convert big number to simple integer format.
  2065.  
  2066.       Parameters:    A big number x.
  2067.  
  2068.       Return value:  The value of x as an integer. If this is not possible
  2069.                      (because x is too big) it returns the value plus or minus
  2070.                      TOOBIG.
  2071.  
  2072.       Restrictions:  None
  2073.  
  2074.       See also:      -
  2075.  
  2076.  
  2077.       Function:      int smul(x,y,z)
  2078.                          smul       
  2079.                      int x,y,z;
  2080.  
  2081.       Module:        bnsmall.c
  2082.  
  2083.       Description:   Multiplies two integers mod a third
  2084.  
  2085.       Parameters:    Integers x, y and z
  2086.  
  2087.       Return value:  (x.y) mod z
  2088.  
  2089.       Restrictions:  None
  2090.  
  2091.       See also:      spmd
  2092.  
  2093.  
  2094.       Function:      int spmd(x,y,z)
  2095.                          spmd       
  2096.                      int x,y,z;
  2097.  
  2098.       Module:        bnsmall.c
  2099.  
  2100.       Description:   Raises an integer to an integer power modulus a third
  2101.  
  2102.       Parameters:    Integers x, y, and z
  2103.  
  2104.       Return value:  x^y mod z
  2105.  
  2106.       Restrictions:  None
  2107.  
  2108.       See also:      smul
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.  
  2115.  
  2116.  
  2117.  
  2118.  
  2119.  
  2120.  
  2121.  
  2122.  
  2123.  
  2124.  
  2125.  
  2126.  
  2127.       Function:      int sqrmp(x,y)
  2128.                          sqrmp     
  2129.                      int x,y;
  2130.  
  2131.       Module:        bnsmall.c
  2132.  
  2133.       Description:   Calculates the square root of an integer mod an integer
  2134.                      prime number
  2135.  
  2136.       Parameters:    An integer x and a prime number y
  2137.  
  2138.       Return value:  x^(1/2) mod y, or 0 if root does not exist
  2139.  
  2140.       Restrictions:  Return value unpredictable if y is not prime
  2141.  
  2142.       See also:      inverse
  2143.  
  2144.  
  2145.       Function:      void strongp(p,n)
  2146.                           strongp     
  2147.                      big p;
  2148.                      int n;
  2149.  
  2150.       Module:        bnprime.c
  2151.  
  2152.       Description:   Generate a 'strong' prime number. Useful for Public Key
  2153.                      Cryptography programs.
  2154.  
  2155.       Parameters:    A big number p and an integer n. On exit p will contain
  2156.                      a 'strong' prime number at least n decimal digits long.
  2157.  
  2158.       Return value:  None
  2159.  
  2160.       Restrictions:  None. The prime p may be rather more than n digits long.
  2161.  
  2162.       See also:      prime, nxprime
  2163.  
  2164.  
  2165.  
  2166.       Function:      int subdiv(x,n,z)
  2167.                          subdiv       
  2168.                      int n;
  2169.                      big x,z;
  2170.  
  2171.       Module:        bnarth1.c
  2172.  
  2173.       Description:   Divide a big number by an integer.
  2174.  
  2175.       Parameters:    Two big numbers x and z, and an integer n. On exit z=x/n.
  2176.  
  2177.       Return value:  The integer remainder.
  2178.  
  2179.       Restrictions:  The value of n must not be zero.
  2180.  
  2181.       See also:      premult
  2182.  
  2183.  
  2184.  
  2185.  
  2186.  
  2187.  
  2188.  
  2189.  
  2190.  
  2191.  
  2192.  
  2193.  
  2194.  
  2195.  
  2196.       Function:      void subtract(x,y,z)
  2197.                           subtract       
  2198.                      big x,y,z;
  2199.  
  2200.       Module:        bnarth0.c
  2201.  
  2202.       Description:   Subtracts two big numbers.
  2203.  
  2204.       Parameters:    Three big numbers x, y and z. On exit z=x-y.
  2205.  
  2206.       Return value:  None
  2207.  
  2208.       Restrictions:  None
  2209.  
  2210.       See Also:      add, incr, decr.
  2211.  
  2212.  
  2213.  
  2214.       Function:      int xgcd(x,y,xd,yd,z)
  2215.                          xgcd             
  2216.                      big x,y,xd,yd,z;
  2217.  
  2218.       Module:        bnxgcd.c
  2219.  
  2220.       Description:   Calculates extended Greatest Common Divisor of two big
  2221.                      numbers. Can also be used to calculate modular inverses.
  2222.                      Note that this routine is about 8 times slower than a
  2223.                      'mad' operation on numbers of similar size.
  2224.  
  2225.       Parameters:    Five big numbers x,y,xd,yd and z.
  2226.                      On exit z=gcd(x,y)=x.xd+y.yd
  2227.  
  2228.       Return value:  GCD as integer, if possible, otherwise TOOBIG
  2229.  
  2230.       Restrictions:  If xd and yd are not distinct, only xd is returned. The
  2231.                      GCD is only returned if z distinct from both xd and yd.
  2232.  
  2233.       See also:      gcd, round
  2234.  
  2235.       Example:       xgcd(x,p,x,x,x);  /* x = 1/x mod p  (p is prime) */
  2236.  
  2237.  
  2238.  
  2239.       Function:      void zero(x)
  2240.                           zero   
  2241.                      flash x;
  2242.  
  2243.       Module:        bncore.c
  2244.  
  2245.       Description:   Sets a big or flash number to zero
  2246.  
  2247.       Parameters:    A big or flash number x.
  2248.  
  2249.       Return value:  None
  2250.  
  2251.       Restrictions:  None
  2252.  
  2253.       See also:      -
  2254.  
  2255.  
  2256.  
  2257.  
  2258.  
  2259.  
  2260.  
  2261.  
  2262.  
  2263.  
  2264.  
  2265.                       Appendix IV  - Example programs
  2266.  
  2267.  
  2268.       Note:  The programs described here are of an experimental nature, and
  2269.       in  many  cases  are  not  completely  'finished  off'.  For  further
  2270.       information read the comments associated with the appropriate  source
  2271.       file.
  2272.  
  2273.       Program:          hail.c
  2274.                         hail.c
  2275.  
  2276.       This  program  allows you to investigate so-called hailstone numbers,
  2277.       as  described  by  Fred  Gruenberger   in   'Computer   Recreations',
  2278.       Scientific American,  April 1984.  The procedure is simple.  Starting
  2279.       with any number apply the following rules:
  2280.  
  2281.       (a) If it is odd, multiply it by 3 and add 1.
  2282.  
  2283.       (b) If it is even, divide it by 2.
  2284.  
  2285.       (c) Repeat the process,  until the number becomes equal to 1, in which
  2286.           case stop.
  2287.  
  2288.       It would appear that for  any  initial  number  this  process  always
  2289.       eventually terminates, although it has not been proved that this must
  2290.       happen,  or  that  the process can not get stuck in an infinite loop.
  2291.       What goes up,  it seems,  must come down.  Try  the  program  for  an
  2292.       initial value of 27. Then try it using much bigger numbers.
  2293.  
  2294.  
  2295.  
  2296.       Program:          palin.c
  2297.                         palin.c
  2298.  
  2299.       This  programs  allows you to investigate palindromic reversals.  See
  2300.       'Computer Recreations'  by  Fred  Gruenberger,  Scientific  American,
  2301.       April 1984.  A palindromic number is one which reads the same in both
  2302.       directions.  Start with any number and apply the following rules.
  2303.  
  2304.       (a)  Add  the number to the number obtained by reversing the order of
  2305.           the digits. Make this the new number.
  2306.  
  2307.       (b) Stop the process when the new number is palindromic.
  2308.  
  2309.  
  2310.       It appears  that  for  most  initial  numbers  this  process  quickly
  2311.       terminates.  Try it for 89. Then try it for 196.
  2312.  
  2313.  
  2314.       Program:          brute.c
  2315.                         brute.c
  2316.  
  2317.       This  program attempts to factorise a number by brute force division,
  2318.       using a table of small prime numbers. When  attempting a difficult
  2319.       factorisation it makes sense to try this approach first.
  2320.       Use  this  program to factorise 12345678901234567890.  Then try it on
  2321.       bigger random numbers.
  2322.  
  2323.  
  2324.  
  2325.  
  2326.  
  2327.  
  2328.  
  2329.  
  2330.  
  2331.  
  2332.  
  2333.  
  2334.       Program:          brent.c
  2335.                         brent.c
  2336.  
  2337.       This program attempts to factorise a number using  the  Brent-Pollard
  2338.       method.  This  method  is  faster  at finding larger factors than the
  2339.       simple-minded brute  force  approach.  However  it  will  not  always
  2340.       succeed,  even  for  very simple factorisations.  Use it to factorise
  2341.       R17, that is 11111111111111111 (seventeen ones). Then try it on larger
  2342.       numbers that would not yield to the brute force approach.
  2343.  
  2344.  
  2345.       Program:          pollard.c
  2346.                         pollard.c
  2347.  
  2348.       Another factoring program, which implements Pollard's (p-1) method,
  2349.       specialises in quickly finding a factor p of  a number  N  for  which
  2350.       (p-1) has itself only small factors. Phase 1 of this method will work
  2351.       if all these small factors are less  than  LIMIT1. If  Phase 1  fails
  2352.       then Phase 2 searches for just one  final  larger factor less  than
  2353.       LIMIT2. The constants LIMIT1 and LIMIT2 are set inside the program.
  2354.  
  2355.  
  2356.       Program:          williams.c
  2357.                         williams.c
  2358.  
  2359.       This program is similar to Pollards method, but can find a factor p
  2360.       of N for which (p+1) has only small factors. Again two phases are
  2361.       used. In fact this method is sometimes a (p+1) method, and sometimes
  2362.       a (p-1) method, so several attempts are made to find the (p+1)
  2363.       condition. The algorithm is rather more complex than that used in
  2364.       Pollards method, and is somewhat slower.
  2365.  
  2366.  
  2367.       Program:          lenstra.c
  2368.                         lenstra.c
  2369.  
  2370.       Recently Lenstra has discovered a new method of factorisation,
  2371.       generically similar to the Pollard and Williams methods, but
  2372.       potentially much more powerful. It works by randomly generating an
  2373.       Elliptic Curve, which can then be used to find a factor p of N, for
  2374.       which p+1-d has only small factors, where d depends on the particular
  2375.       curve chosen. If one curve fails then another can be tried, an option
  2376.       not possible with the Pollard/Williams methods. Again this is a two
  2377.       phase method, and although it has very good asymptotic behaviour, it
  2378.       is much slower than the pollard/williams for each iteration.
  2379.  
  2380.  
  2381.  
  2382.  
  2383.  
  2384.  
  2385.  
  2386.  
  2387.  
  2388.  
  2389.  
  2390.  
  2391.  
  2392.  
  2393.  
  2394.  
  2395.  
  2396.  
  2397.  
  2398.  
  2399.  
  2400.  
  2401.  
  2402.  
  2403.  
  2404.       Program:          qsieve.c
  2405.                         qsieve.c
  2406.  
  2407.       This is a  very  sophisticated Pomerance-Silverman-Montgomery
  2408.       factoring  program.  Its  speciality  is factoring all numbers (up to
  2409.       about sixty digits long), irrespective of the size of the factors. If
  2410.       the number to be factored is N,  then the program actually works with
  2411.       a  number  k.N,  where  k is a small Knuth-Schroepel multiplier.  The
  2412.       program itself works out the best value of k to use. Internally,  the
  2413.       program uses a 'factor base' of small primes. The larger the number,
  2414.       the bigger will be  this  factor  base.  The  program  works  by
  2415.       accumulating information from a number of simpler factorisations. As
  2416.       it progresses with these it prints out 'working...n'.  When it thinks
  2417.       it has enough information it prints out 'trying',  but these tries
  2418.       may be premature and  may  not  succeed.  The program will always
  2419.       terminate before the number n in 'working...n' reaches the size of
  2420.       the factor base.
  2421.  
  2422.  
  2423.       This program uses much more memory than  any  of  the  other  example
  2424.       programs,  particularly when factoring bigger numbers.  The amount of
  2425.       memory that the program can take is limited by the values defined for
  2426.       MEM and MLF  at  the  beginning  of  the  program.  These  should  be
  2427.       increased  if possible,  or reduced if your computer has insufficient
  2428.       memory.
  2429.  
  2430.       Use qsieve to factor 10000000000000000000000000000000009 (thirty-
  2431.       five digits).
  2432.  
  2433.  
  2434.       Program:          mersenne.c
  2435.                         mersenne.c
  2436.  
  2437.       This program generates all prime  numbers  of  the  form  2^n-1.  The
  2438.       largest  known  primes  have  always been of this form because of the
  2439.       efficiency of this Lucas-Lehmer test.
  2440.  
  2441.  
  2442.  
  2443.  
  2444.  
  2445.  
  2446.  
  2447.  
  2448.  
  2449.  
  2450.  
  2451.  
  2452.  
  2453.  
  2454.  
  2455.  
  2456.  
  2457.  
  2458.  
  2459.  
  2460.  
  2461.  
  2462.  
  2463.  
  2464.  
  2465.  
  2466.  
  2467.  
  2468.  
  2469.  
  2470.  
  2471.  
  2472.       Program:          rsakey.c
  2473.                         rsakey.c
  2474.  
  2475.       Public  Key  Cryptography  is  a two key encipherment system with the
  2476.       very desirable feature that the encoding key  can  be  made  publicly
  2477.       available, without weakening the strength of the cipher. This program
  2478.       generates  the  'public'  encoding key and 'private' decoding key for
  2479.       the original Rivest-Shamir-Adleman PKS system.  These keys can take a
  2480.       long  time  to  generate,  as  they  are formed from very large prime
  2481.       numbers, which must be generated carefully for maximum security.
  2482.  
  2483.  
  2484.       The program prompts for 'Minimum size of keys in decimal digits'. The
  2485.       security of the system depends on the  difficulty  of  factoring  the
  2486.       encoding  'public'  key,  which is formed from two large primes.  The
  2487.       largest numbers which  can  be  routinely  factored  using  the  most
  2488.       powerful computers are 100 digits long (1988). So a minimum size of
  2489.       120 gives adequate security (for now!)
  2490.  
  2491.       After  this  program  has  run,  the  two  keys  are created in files
  2492.       PUBLIC.KEY and PRIVATE.KEY.
  2493.  
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.  
  2502.  
  2503.  
  2504.  
  2505.  
  2506.  
  2507.  
  2508.  
  2509.  
  2510.  
  2511.  
  2512.  
  2513.  
  2514.  
  2515.  
  2516.  
  2517.  
  2518.  
  2519.  
  2520.  
  2521.  
  2522.  
  2523.  
  2524.  
  2525.  
  2526.  
  2527.  
  2528.  
  2529.  
  2530.  
  2531.  
  2532.  
  2533.  
  2534.  
  2535.  
  2536.  
  2537.  
  2538.  
  2539.       Program:          encode.c
  2540.                         encode.c
  2541.  
  2542.       Messages or files may be encoded with this program,  which  uses  the
  2543.       'public'  encoding  key  from  the file PUBLIC.KEY,  generated by the
  2544.       program 'rsakey',  which must have  been  run  prior  to  using  this
  2545.       program.  When run the user is  prompted  for  a  file  to  encipher.
  2546.       Either  give  the  name  of  a text file,  or press return to enter a
  2547.       message directly from the keyboard.  In the former case  the  encoded
  2548.       output  is sent to a file with the same name,  but with the extension
  2549.        .RSA.  In the latter case you are prompted for an  output  filename,
  2550.       which  must  be  given.  Text  entered  from  the  keyboard  must  be
  2551.       terminated by a CONTROL Z (end-of-file).  Type out the  encoded  file
  2552.       and be impressed by how indecipherable it looks
  2553.  
  2554.       Program:          decode.c
  2555.                         decode.c
  2556.  
  2557.       Messages or files encoded using the RSA system may be  decoded  using
  2558.       this  program,  which  uses  the 'private' decoding key from the file
  2559.       PRIVATE.KEY generated by the program 'rsakey' which  must  have  been
  2560.       run at some stage prior to using this program.
  2561.  
  2562.       When  run,  the  user  is  prompted  for  the  name of the file to be
  2563.       decoded.  Type in the filename (without an extension  -  the  program
  2564.       will  assume  the extension .RSA) and press return.  Then the user is
  2565.       asked for an output filename.  Either  supply  a  filename  or  press
  2566.       return, in which case the decoded output will be sent straight to the
  2567.       screen.  A problem with the RSA system becomes immediately apparent -
  2568.       decoding takes a very long time! This is particularly true for larger
  2569.       key sizes and long messages.
  2570.  
  2571.  
  2572.  
  2573.  
  2574.  
  2575.  
  2576.  
  2577.  
  2578.  
  2579.  
  2580.  
  2581.  
  2582.  
  2583.  
  2584.  
  2585.  
  2586.  
  2587.  
  2588.  
  2589.  
  2590.  
  2591.  
  2592.  
  2593.  
  2594.  
  2595.  
  2596.  
  2597.  
  2598.  
  2599.  
  2600.  
  2601.  
  2602.  
  2603.  
  2604.  
  2605.  
  2606.  
  2607.       Program:          okakey.c
  2608.                         okakey.c
  2609.  
  2610.       This  program  generates 'public' and 'private' keys for use with the
  2611.       Okamoto PKS system.  As with the RSA system the  keys  are  generated
  2612.       from  large  prime numbers carefully selected for certain properties,
  2613.       so this program takes a long time to run.  A key  length  of  150  is
  2614.       adequate.  The  two  keys  are  generated  into  files PUBLIC.KEY and
  2615.       PRIVATE.KEY.
  2616.  
  2617.  
  2618.       Program:          enciph.c
  2619.                         enciph.c
  2620.  
  2621.       This program works in an identical fashion to the  program  'encode',
  2622.       although  in  this case the encoded file produced will be 1.35 times
  2623.       bigger than the original.
  2624.  
  2625.  
  2626.       Program:          deciph.c
  2627.                         deciph.c
  2628.  
  2629.       This program works in an identical fashion to the  program  'decode'.
  2630.       However it has the advantage that it runs much more quickly.
  2631.  
  2632.       Note : The original version of this program was 'cracked' by the
  2633.       redoubtable Shamir. Okamoto (Electronics letters 30th July 1987, Vol.
  2634.       23 No. 16 pp814-815) responded with a modified algorithm which
  2635.       appears to be resistant to Shamirs method of attack. This improved
  2636.       version has now been implemented. Over to you Shamir...
  2637.  
  2638.  
  2639.       Program:          pi.c
  2640.                         pi.c
  2641.  
  2642.       This  program  calculates  pi  using  a  Guass-Legendre  O(n².log(n))
  2643.       method.  (Is there a more efficient way to calculate pi for  moderate
  2644.       n?)  The  greater  the  precision  specified  in  the call to routine
  2645.       'mirsys', the more decimal place there will be in the answer (and the
  2646.       longer it will take).
  2647.  
  2648.  
  2649.       Program:          roots.c
  2650.                         roots.c
  2651.  
  2652.       This program calculates the n-th  root  of  an  input  number,  using
  2653.       Newtons method. Try it to calculate the square root of two. Again the
  2654.       accuracy  obtained  depends  on  the  size  of  the  flash variables,
  2655.       specified in routine 'mirsys'.  The tendency of flash  arithmetic  to
  2656.       prefer  simple  numbers  can be illustrated by requesting,  say,  the
  2657.       square root of 7.  The program calculates this value and then squares
  2658.       it,  to give 7 again exactly.  On your  pocket  calculator  the  same
  2659.       result  will only be obtained if clever use is made of extra (hidden)
  2660.       guard digits.
  2661.  
  2662.  
  2663.       Program:          hilbert.c
  2664.                         hilbert.c
  2665.  
  2666.       Traditionally the inversion of 'Hilbert' matrices is  regarded  as  a
  2667.       tough test for any system of arithmetic. This programs solves the set
  2668.       of linear equations H.x = b, where H is a Hilbert matrix and b is the
  2669.       vector  [1,1,1,1,....1],  using  the  classical  Guassian Elimination
  2670.       method.
  2671.  
  2672.  
  2673.  
  2674.  
  2675.  
  2676.  
  2677.  
  2678.  
  2679.       Program:          sample.c
  2680.                         sample.c
  2681.  
  2682.       This program is the same as that used by Brent (1978) to  demonstrate
  2683.       some  of  the  capabilities  of his Fortran Multiprecision arithmetic
  2684.       package. It calculates pi, exp(pi*sqrt(163/9)) and exp(pi*sqrt(163)).
  2685.  
  2686.  
  2687.       Program:          ratcalc.c
  2688.                         ratcalc.c
  2689.  
  2690.       As a comprehensive and useful demonstration of flash arithmetic  this
  2691.       program simulates a standard full-function scientific calculator. Its
  2692.       unique feature (besides its 36-digit accuracy) is its ability to work
  2693.       directly with fractions, and to handle mixed  calculations  involving
  2694.       both fractions and decimals. By using  this  program  the  user  will
  2695.       quickly  get  a feel for flash arithmetic and its capabilities.  Note
  2696.       that this program contains some non-portable  code  (screen  handling
  2697.       routines) that must be tailored to each individual  computer/terminal
  2698.       combination.
  2699.  
  2700.  
  2701.  
  2702.  
  2703.  
  2704.  
  2705.  
  2706.  
  2707.  
  2708.  
  2709.  
  2710.  
  2711.  
  2712.  
  2713.  
  2714.  
  2715.  
  2716.  
  2717.  
  2718.  
  2719.  
  2720.  
  2721.  
  2722.  
  2723.  
  2724.  
  2725.  
  2726.  
  2727.  
  2728.  
  2729.  
  2730.  
  2731.  
  2732.  
  2733.  
  2734.  
  2735.  
  2736.  
  2737.  
  2738.  
  2739.  
  2740.  
  2741.  
  2742.  
  2743.  
  2744.  
  2745.  
  2746.